package uilts
{
	import flash.display.Loader;
	import flash.errors.IOError;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import interfaces.ILoader;
	
	public class LoadXML implements ILoader
	{
		private var loadXML:ILoader;
		private var urlXML:String;

		private var loader:URLLoader;
		public function LoadXML(_loadXML:ILoader,_urlXML:String)
		{
			loadXML = _loadXML;
			urlXML = _urlXML;
			loading();
		}
		private function loading():void{
			if(loader == null){
				loader = new URLLoader();
			}
			loader.addEventListener(Event.COMPLETE,onComplete);
			loader.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
			loader.load(new URLRequest(urlXML));
		}
		
		public function onComplete(event:Event):void
		{
			trace("XML加载完成");
			loadXML.onComplete(event);
		}
		
		public function onIOError(event:IOError):void
		{
			trace("XML加载失败");
		}
	}
}